﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Data;
using System.Windows.Media.Imaging;

namespace SharePoint.Security.ConfigAnalyzer.Client.Converters
{
    public class RuleStatusToImageConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, string language)
        {
            var val = value.ToString();

            if (val == "Fail")
            {
                return new BitmapImage(new Uri(@"pack://application:,,,/Images/ToastError.png"));
            }
            if (val == "Pass")
            {
                return new BitmapImage(new Uri(@"pack://application:,,,/Images/ToastOk.png"));
            }
            if (val == "InConclusive")
            {
                return new BitmapImage(new Uri(@"pack://application:,,,/Images/Inconclusive.png"));
            }

            return new BitmapImage();
        }

        public object ConvertBack(object value, Type targetType, object parameter, string language)
        {
            throw new NotImplementedException();
        }

        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            var val = value.ToString();

            if (val == "Fail")
            {
                return new BitmapImage(new Uri(@"pack://application:,,,/Images/ToastError.png"));
            }
            if (val == "Pass")
            {
                return new BitmapImage(new Uri(@"pack://application:,,,/Images/ToastOk.png"));
            }
            if (val == "InConclusive")
            {
                return new BitmapImage(new Uri(@"pack://application:,,,/Images/Warn.png"));
            }

            return new BitmapImage();
        }

        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }
}
